/* 公共域名 */
/* 路段坐标 */
let roadArrayBd = [];
/* 桥梁坐标 */
let bridgeArrayBd = [];
/* 隧道坐标 */
let tunnelArrayBd = [];
/* 检查井坐标 */
let wellArrayBd = [];
/* 开挖监管坐标 */
let excavateArrayBd = [];
/* 病害预结算坐标 */
let diseaseArrayBd = [];
let ssyhSelectId = '';
//画出道路路线 
function setDaoluXian(){
    let allPointList = [];
    //画出道路路线
    var fOverLayears = $('#roadSelect2').find('option[value="'+ssyhSelectId+'"]').attr('id');
    if (fOverLayears == null || fOverLayears == 'null') {
        map.clearOverlays();
    }else{
        map.clearOverlays();
        var data = JSON.parse(fOverLayears);
        allPointList = allPointList.concat(data);
        commanDrwaing(data, '', 'pointLine', 'orange', 0);
    }
    return allPointList;
}
$(function () {
	function bindRoadSelect() {
		$("#roadSelect option:not(:first)").remove();
		$.get(baseUrl +'dlssxx/main/daoluxx/loadallroads', function(data) {
			var _op = "";
			for (let i = 0; i < data.length; i++) {
				_op += "<option value='" + data[i].fid + "' id='" + data[i].fOverLayears + "'>" + data[i].fRoadName + "</option>"
			}
			$("#roadSelect2").append(_op);
			layuiSelectRender();
			arrdata = data;
			let overLays = [];
			for (let j = 0; j < data.length; j++) {
				jsonOverlayears = JSON.parse(data[j].fOverLayears);
				if (jsonOverlayears == null) continue;
				overLays = overLays.concat(jsonOverlayears);
				commanDrwaing(jsonOverlayears, '', 'pointLine', 'orange',0);
			}
			setCenterAndZoom(overLays);
		});
	};
    //layui 设施养护下拉选择框 监听事件
    layui.form.on('select(sheshiSelect)', function(data){
        //清除聚合点
        clearCheckBox();

        var roadID = data.value;
        ssyhSelectId = roadID;
        countData(roadID);
        $('.way4').parent().find('.left-list ul>li>a').removeClass('curr');
        map.clearOverlays();
        var fOverLayears = $('#roadSelect2').find('option[value="'+data.value+'"]').attr('id');
        if (fOverLayears == null || fOverLayears == 'null') {
            return;
        }
        var data = JSON.parse(fOverLayears);
        setCenterAndZoom(data);
        commanDrwaing(data, '', 'pointLine', 'orange', 0);
        facilityMaintenance.ssyhClick(roadID);
    });
	//监听路段选择下拉框
		layui.form.on('select(roadluduan2)', function(data){
			let allPointList = [];
			//画出道路路线
			var fOverLayears = $('#roadSelect2').find('option[value="'+ssyhSelectId+'"]').attr('id');
			console.log(fOverLayears)
			if (fOverLayears == null || fOverLayears == 'null') {
				map.clearOverlays();
			}else{
				map.clearOverlays();
				var data = JSON.parse(fOverLayears);
				allPointList = allPointList.concat(data);
				commanDrwaing(data, '', 'pointLine', 'orange', 0);
			}
	
			var overLays = JSON.parse($("#roadluduan2 option:checked").attr("id"));
			var selectData = JSON.parse($("#roadluduan2 option:checked").attr("name"));
	
			if(!overLays){
				commanDrwaing(allPointList, '', 'pointLine', 'red', 0);
				setCenterAndZoom(allPointList);
				return;
			}
			commanDrwaing(overLays, '', 'pointLine', 'red',1,selectData);
			allPointList = allPointList.concat(selectData);
			setCenterAndZoom(allPointList);
		 });
	
	function selectLuduan(obj){
	console.log('路段信息'+obj);
		var roadID = obj;
		// if (roadID == null || roadID == '' || roadID == 'all') {
		// 	layui.layer.open({
		// 		content: '请选择道路'
		// 	});
		// 	$(this).removeClass("curr")
		// 	return;
		// } else {
		// 	$.get(baseUrl +'dlssxx/main/daoluldxx/loadroadsections', {
		// 		roadID: roadID
		// 	}, function(data) {
		// 		//追加道路信息
		// 		var _op = "<option value='all'>请选择路段</option>";
		// 		for (let i = 0; i < data.length; i++) {
		// 			_op += "<option name ='"+JSON.stringify(data[i])+"' value='" + data[i].fid + "' id='" + data[i].fOverLayears + "'>" + data[i].fRoadSectionName + "</option>"
		// 		}
		// 		$("#roadluduan").empty();
		// 		$("#roadluduan").append(_op);
		// 		layuiSelectRender();
		//
		// 	})
		// }
		
		$.get(baseUrl +'dlssxx/main/daoluldxx/loadroadsections', {
			roadID: roadID
		}, function(data) {
			//追加道路信息
			var _op = "<option value='all'>请选择路段</option>";
			for (let i = 0; i < data.length; i++) {
				_op += "<option name ='"+JSON.stringify(data[i])+"' value='" + data[i].fid + "' id='" + data[i].fOverLayears + "'>" + data[i].fRoadSectionName + "</option>"
			}
			$("#roadluduan2").empty();
			$("#roadluduan2").append(_op);
			layuiSelectRender();
	
		})
	}
	function countData(roadID) {
		if (roadID == null) {
			$.get(baseUrl +'dlssxx/main/daoluxx/roadassetaccount', function(data) {
				var jsondata = JSON.parse(data);
				//$('#roadSection').find('strong').html(jsondata.roadSectionNum);
				$('#brige').find('strong').html(jsondata.bridgeNum);
				$('#tunnl').find('strong').html(jsondata.tunnelNum);
				$('#manhole').find('strong').html(jsondata.manholeNum);
				$('#other').find('strong').html(jsondata.otherNum);
	
				selectLuduan(roadID);//路段
			})
		} else {
			$.get(baseUrl +'dlssxx/main/daoluxx/roadassetaccount', {
				roadID: roadID
			}, function(data) {
				var jsondata1 = JSON.parse(data);
				//$('#roadSection').find('strong').html(jsondata1.roadSectionNum);
				$('#brige').find('strong').html(jsondata1.bridgeNum);
				$('#tunnl').find('strong').html(jsondata1.tunnelNum);
				$('#manhole').find('strong').html(jsondata1.manholeNum);
				$('#other').find('strong').html(jsondata1.otherNum);
	
				selectLuduan(roadID);//路段
	
			})
		}
	}
	function bindRoadFsSelect(roadId){
		$("#roadFsSelect option:not(:first)").remove();
		let url = baseUrl +'dlssxx/main/daoluxx/roadassetaccount';
		if(roadId){
			url += '?roadID='+roadId;
		}
		$.get(url, function(res) {
			let data = JSON.parse(res);
			var _op = "";
			for (let i = 0; i < data.roadIncludeAssets.length; i++) {
				_op += '<option value="'+ data.roadIncludeAssets[i].fAssetClassDictId +'" num="'+ data.roadIncludeAssets[i].count +'">'+ data.roadIncludeAssets[i].fClassName +'</option>';
			}
			$("#roadFsSelect").append(_op);
			layuiSelectRender();
		});
	}
	// function bindRoadSelect() {
	// 	$("#roadSelect2 option:not(:first)").remove();
	// 	$.get(baseUrl +'dlssxx/main/daoluxx/loadallroads', function(data) {
	// 		var _op = "";
	// 		for (let i = 0; i < data.length; i++) {
	// 			_op += "<option value='" + data[i].fid + "' id='" + data[i].fOverLayears + "'>" + data[i].fRoadName + "</option>"
	// 		}
	// 		$("#roadSelect2").append(_op);
 //            layui.form.render("select");	
	// 	});
	// }
	
    
    //加载设施养护并在道路上绘制道路
    bindRoadSelect();
	// bindRoadFsSelect();
	countData(null)
    /* 入口函数 */
    let facilityMaintenance = {
        init: function () {
            this.defaultClick();
        },
        /* 初始化按钮 */
        defaultClick: function () {
            /* 路段点击事件 */
            $('#road-obj').on('click', function () {
                clearCheckBox();
                var roadID = ssyhSelectId;
                if (roadID == null || roadID == '') {
                    layui.layer.open({
                      content: '请选择道路'
                    });     
                    $(this).removeClass("curr")     
                    return;
                }
				// map.clearOverlays();
                console.info('road-obj: ', roadArrayBd);
                facilityMaintenanceObj.setMarker(roadArrayBd, 's-d.png', 1);
            });
            /* 桥梁点击事件 */
            $('#bridge-obj').on('click', function () {
                clearCheckBox();
                var roadID = ssyhSelectId;
                if (roadID == null || roadID == '') {
                    layui.layer.open({
                      content: '请选择道路'
                    });     
                    $(this).removeClass("curr")     
                    return;
                }
				// map.clearOverlays();
                console.info('bridge-obj: ', bridgeArrayBd);
                facilityMaintenanceObj.setMarker(bridgeArrayBd, 's-q.png', 2);
            });
            /* 隧道点击事件 */
            $('#tunnel-obj').on('click', function () {
                clearCheckBox();
                var roadID = ssyhSelectId;
                if (roadID == null || roadID == '') {
                    layui.layer.open({
                      content: '请选择道路'
                    });     
                    $(this).removeClass("curr")     
                    return;
                }
				// map.clearOverlays();
                console.info('tunnel-obj: ', tunnelArrayBd);
                facilityMaintenanceObj.setMarker(tunnelArrayBd, 's-sd.png', 3);
            });
            /* 检查井点击事件 */
            $('#well-obj').on('click', function () {
                clearCheckBox();

                var roadID = ssyhSelectId;
                if (roadID == null || roadID == '') {
                    layui.layer.open({
                      content: '请选择道路'
                    });     
                    $(this).removeClass("curr")     
                    return;
                }
				// map.clearOverlays();
                console.info('well-obj: ', wellArrayBd);
                facilityMaintenanceObj.setMarker(wellArrayBd, 's-j.png', 4);
            });
            /* 开挖点击事件 */
            $('#excavate-obj').on('click', function () {
                clearCheckBox();

                var roadID = ssyhSelectId;
                if (roadID == null || roadID == '') {
                    layui.layer.open({
                      content: '请选择道路'
                    });     
                    $(this).removeClass("curr")     
                    return;
                }
				// map.clearOverlays();
                console.info('excavate-obj: ', excavateArrayBd);
                facilityMaintenanceObj.setMarker(excavateArrayBd, 's-w.png', 5);
            });
            /* 病害预结算点击事件 */
            $('#disease-obj').on('click', function () {
                clearCheckBox();

                var roadID = ssyhSelectId;
                if (roadID == null || roadID == '') {
                    layui.layer.open({
                      content: '请选择道路'
                    });     
                    $(this).removeClass("curr")     
                    return;
                }
				// map.clearOverlays();
                console.info('disease-obj: ', diseaseArrayBd);
                facilityMaintenanceObj.setMarker(diseaseArrayBd, 's-h.png', 6);
            });
            /* 选择道路绑定事件 */
        },
        ssyhClick:function(roadVal){
            facilityMaintenanceObj.setSum('road-obj', 0);
            facilityMaintenanceObj.setSum('bridge-obj', 0);
            facilityMaintenanceObj.setSum('tunnel-obj', 0);
            facilityMaintenanceObj.setSum('well-obj', 0);
            facilityMaintenanceObj.setSum('excavate-obj', 0);
            facilityMaintenanceObj.setSum('disease-obj', 0);
            /* 获取开始时间 */
           // let startTime = $('#startTime').val();
            /* 获取结束时间 */
           // let endTime = $('#endTime').val();
            /* 当前时间 */

            var startTime = JSON.parse(localStorage.getItem("startTime"))
            var endTime = JSON.parse(localStorage.getItem("endTime"))

            let jsonDate = facilityMaintenanceObj.setDate(startTime, endTime);
            facilityMaintenanceObj.setRoadSum(jsonDate.startTime, jsonDate.endTime, roadVal);
            facilityMaintenanceObj.setExcavationInfo(jsonDate.startTime, jsonDate.endTime, roadVal);
        }
    }
    facilityMaintenance.init();
});

/**
 * 封装函数
 * @type {{}}
 */
let facilityMaintenanceObj = {
    /**
     * 点击设施养护
     */
    clickFacilityMaintenance: function () {
        this.setRoadSum();
        this.setExcavationInfo();
    },
    /**
     * 路段信息
     * @param startTime 开始日期
     * @param endTime 结束日期
     * @param roadId 道路主键
     */
    setRoadSum: function (startTime, endTime, roadId) {
        /* 当前时间 */
        let jsonDate = facilityMaintenanceObj.setDate(startTime, endTime);
		// var startTime = JSON.parse(localStorage.getItem("startTime"))
		// var endTime = JSON.parse(localStorage.getItem("endTime"))
        if (typeof (roadId) === 'undefined' || roadId === '') {
            roadId = 0;
        }
        let that = this;
        ajax.get(baseUrl + "/dlssxx/main/dzdp/getroadsectioninfolist?startTime=" + jsonDate.startTime + "&endTime=" + jsonDate.endTime + "&roadId=" + roadId, {}, false)
            .then(res => {
                /* 接收路段主键 */
                let roadArrayIds = [];
                roadArrayBd = [];
                bridgeArrayBd = [];
                /* 隧道坐标 */
                tunnelArrayBd = [];
                /* 检查井坐标 */
                wellArrayBd = [];
                /* 病害预结算坐标 */
                diseaseArrayBd = [];
                /* 转换成json对象 */
                let jsonData = JSON.parse(res);
                if (jsonData.flag) {
                    if (jsonData.mapList.length > 0) {
                        /* 路段赋值 */
                        that.setSum('road-obj', jsonData.mapList.length);
                        jsonData.mapList.forEach((item, i) => {
                            roadArrayIds.push(item.lfid);
                            /* 封装坐标 */
                            item.lat = item.bdlat;
                            item.lng = item.bdlon;
                            roadArrayBd.push(item);
                        });
                        if (roadArrayIds.length > 0) {
                            /* 去掉重复路段主键后数据集 */
                            roadArrayIds = that.setDeduplication(roadArrayIds);
                            /* 桥梁信息 */
                            that.getBridgeInfos(roadArrayIds);
                            /* 隧道信息 */
                            that.getTunnelInfo(roadArrayIds);
                            /* 检查井信息 */
                            that.setManholeInfo(roadArrayIds);
                            /* 病害预结算信息 */
                            that.setDamageInfoCount(jsonDate.startTime, jsonDate.endTime, roadArrayIds);
                        }
                    }
                }
            })
            .catch(err => {
                console.error(err)
            });
    },
    /**
     * 初始化-设施养护数量
     * @param idVal 元素ID
     * @param val 值
     */
    setSum: function (idVal, val) {
        $('#' + idVal).find('strong').html(val);
    },
    /**
     * 获取桥梁信息
     * @param roadArrayIds 路段主键集合
     */
    getBridgeInfos: function (roadArrayIds) {
        let that = this;
        ajax.post(baseUrl + '/dlssxx/main/dzdp/getbridgeinfolist', JSON.stringify(roadArrayIds))
            .then(res => {
                /* 转换成json对象 */
                let jsonData = JSON.parse(res);
                bridgeArrayBd = [];
                if (jsonData.flag) {
                    if (jsonData.mapList.length > 0) {
                        /* 桥梁赋值 */
                        that.setSum('bridge-obj', jsonData.mapList.length);
                        jsonData.mapList.forEach((item, i) => {
                            item.lat = item.bdlat;
                            item.lng = item.bdlon;
                            bridgeArrayBd.push(item);
                        });
                    }
                }
            })
            .catch(err => {
                console.error(err)
            });
    },
    /**
     * 获取隧道信息
     * @param roadArrayIds 路段主键集合
     */
    getTunnelInfo: function (roadArrayIds) {
        let that = this;
        ajax.post(baseUrl + '/dlssxx/main/dzdp/gettunnelinfolist', JSON.stringify(roadArrayIds))
            .then(res => {
                tunnelArrayBd = [];
                /* 转换成json对象 */
                let jsonData = JSON.parse(res);
                if (jsonData.flag) {
                    if (jsonData.mapList.length > 0) {
                        /* 隧道赋值 */
                        that.setSum('tunnel-obj', jsonData.mapList.length);
                        jsonData.mapList.forEach((item, i) => {
                            item.lat = item.bdlat;
                            item.lng = item.bdlon;
                            tunnelArrayBd.push(item);
                        });
                    }
                }
            })
            .catch(err => {
                console.error(err)
            });
    },
    /**
     * 检查井信息
     * @param roadArrayIds 路段主键集合
     */
    setManholeInfo: function (roadArrayIds) {
        let that = this;
        ajax.post(baseUrl + '/jcjgl/main/dzdp/getmanholeinfolistbyroadids', JSON.stringify(roadArrayIds))
            .then(res => {
                wellArrayBd = [];
                /* 转换成json对象 */
                let jsonData = JSON.parse(res);
                if (jsonData.manholeInfos.length > 0) {
                    /* 检查井值 */
                    that.setSum('well-obj', jsonData.total);
                    jsonData.manholeInfos.forEach((item, i) => {
                        item.lat = item.bdlat;
                        item.lng = item.bdlon;
                        wellArrayBd.push(item);
                    });
                }
            })
            .catch(err => {
                console.error(err)
            });
    },
    /**
     * 开挖记录信息
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param fid 道路主键
     */
    setExcavationInfo: function (startTime, endTime, fid) {
        /* 当前时间 */
        let jsonDate = facilityMaintenanceObj.setDate(startTime, endTime);
        if (typeof (fid) === 'undefined' || fid === '') {
            fid = 0;
        }
        let that = this;
        ajax.get(baseUrl + "/dlxy/main/dzdp/getexcavationinfolist?startTime=" + jsonDate.startTime + "&endTime=" + jsonDate.endTime + "&fid=" + fid, {}, false)
            .then(res => {
                excavateArrayBd = [];
                /* 转换成json对象 */
                let jsonData = JSON.parse(res);
                if (jsonData.code === 1) {
                    if (jsonData.dataList.length > 0) {
                        /* 开发记录赋值 */
                        that.setSum('excavate-obj', jsonData.dataList.length);
                        jsonData.dataList.forEach((item, i) => {
                            item.lat = item.bdlat;
                            item.lng = item.bdlon;
                            excavateArrayBd.push(item);
                        });
                    }
                }
            })
            .catch(err => {
                console.error(err)
            });
    },
    /**
     * 病害预结算信息
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param roadArrayIds 路段主键集合
     */
    setDamageInfoCount: function (startTime, endTime, roadArrayIds) {
        let that = this;
        /* 入参对象 */
        let reqJson = {};
        reqJson.startTime = startTime;
        reqJson.endTime = endTime;
        reqJson.roadSections = roadArrayIds;
        ajax.post(baseUrl + '/dlxy/main/dzdp/getdamageinfocount', JSON.stringify(reqJson))
            .then(res => {
                diseaseArrayBd = [];
                /* 转换成json对象 */
                let jsonData = JSON.parse(res);
                if (jsonData.dataInfo.length > 0) {
                    /* 病害预结算赋值 */
                    that.setSum('disease-obj', jsonData.dataInfo.length);
                    jsonData.dataInfo.forEach((item, i) => {
                        item.lat = item.bdlat;
                        item.lng = item.bdlon;
                        diseaseArrayBd.push(item);
                    });
                }
            })
            .catch(err => {
                console.error(err)
            });
    },
    /**
     * 处理查询日期
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @returns {{}}
     */
    setDate: function (startTime, endTime) {
        /* 当前时间 */
        let myDate = new Date();
        if (typeof (startTime) === 'undefined' || startTime === ''
            || typeof (endTime) === 'undefined' || endTime === '') {
            startTime = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
            endTime = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
        }
        let jsonDate = {};
        jsonDate.startTime = startTime;
        jsonDate.endTime = endTime;
        return jsonDate;
    },
    /**
     * 去掉重复的路段ID
     * @param array 数据集
     * @returns {[]}
     */
    setDeduplication: function (array) {
        /* 去掉重复数据 */
        let newArr = [...new Set(array)];
        /* 路段主键对象 */
        let roadArray = [];
        newArr.forEach((item, i) => {
            /* 路段对象 */
            let roadJson = {
                "roadId": item
            }
            roadArray.push(roadJson);
        });
        return roadArray;
    },
    /**
     * 绘制百度地图
     * @param dataArray 弹框信息数据集
     * @param img 坐标图片
     * @param type 1: 路段、2: 桥梁、3: 隧道、4: 检查井、5: 开挖监管、6: 病害预结算
     */
    setMarker: function (dataArray, img, type) {
        /* 坐标对象数组 */
        let pointArr = [];
        let selectArr2 = [];
        dataArray.forEach((item, i) => {
            /* 坐标对象 */
            let point = new BMap.Point(item.lng, item.lat);
            pointArr.push(point);
            selectArr2.push({lng:item.lng,lat:item.lat});
        })
        if (pointArr.length > 0) {
            let allList = setDaoluXian();
            allList = allList.concat(selectArr2);
            setCenterAndZoom(allList);
            pointArr.forEach((item, i) => {
                /* 大点图片 */
                let myIcon = new BMap.Icon("img/" + img + "", new BMap.Size(24, 24));
                /* 创建标注 */
                let marker = new BMap.Marker(item, {
                    icon: myIcon
                });
                marker.dataInfo = dataArray[i];
                /* 将标注添加到地图中 */
                marker.addEventListener("click", function (e) {
                    if (e.target.dataInfo) {
                        /* 获取数据属性 */
                        let dataJson = e.target.dataInfo;
                        if ($(e.currentTarget.Ac).find('.pointDisNCz') && $(e.currentTarget.Ac).find('.pointDisNCz').css('display') === 'block') {
                            $(e.currentTarget.Ac).find('.pointDisNCz').remove();
                        } else {
                            /* 名称 */
                            let name = '';
                            /* 动态页面 */
                            let htmlStr = '<div class="pointDisNCz" style="position:absolute;padding:10px; left: -160px; width:688px; bottom:20px;z-index: 9999;background-color:#1D2127; border: 1px solid #0eb1fd;color:#fff; font-size:16px">'
                                + '<div class="yad-list"><i id="gbclod"><img src="img/icon.png" alt="" /></i><table class="table" style="margin-bottom: 0;">';
                            switch (type) {
                                case 1:
                                    name = dataJson.froadsectionname;
                                    break;
                                case 2:
                                    name = dataJson.fbridgename;
                                    break;
                                case 3:
                                    name = dataJson.fbridgename;
                                    break;
                                default:
                                    name = '--';
                                    break;
                            }
                            /* 拼接弹出窗口内容 */
                            let html;
                            if (type <= 3) {
                                html = '<tr><th>病害编码</th><td>' + dataJson.damagecode + '</td><th>名称</th><td>' + name + '</td></tr>'
                                    + '<tr><th>所属区域</th><td>' + ((typeof (dataJson.LocationName) !== 'undefined') ? dataJson.LocationName : '--') + '</td><th>设施类别</th><td>' + ((typeof (dataJson.DeviceTypeName) !== 'undefined') ? dataJson.DeviceTypeName : '--') + '</td></tr>'
                                    + '<tr><th>设施项目</th><td>' + ((typeof (dataJson.FacilitiesProjectName) !== 'undefined') ? dataJson.FacilitiesProjectName : '--') + '</td><th>病害类型</th><td>' + ((typeof (dataJson.DamageTypeName) !== 'undefined') ? dataJson.DamageTypeName : '--') + '</td></tr>'
                                    + '<tr><th>病害量化</th><td>' + (typeof (dataJson.damagedetail) !== 'undefined' ? dataJson.damagedetail : '--') + '</td><th>规格</th><td>' + ((typeof (dataJson.SpecName) !== 'undefined') ? dataJson.SpecName : '--') + '</td></tr>'
                                    + '<tr><th>颜色</th><td>' + ((typeof (dataJson.ColorName) !== 'undefined') ? dataJson.ColorName : '--') + '</td><th>材质</th><td>' + ((typeof (dataJson.MaterialName) !== 'undefined') ? dataJson.MaterialName : '--') + '</td></tr>'
                                    + '<tr><th>方向</th><td>' + ((typeof (dataJson.DirectionName) !== 'undefined') ? dataJson.DirectionName : '--') + '</td><th>处理类型</th><td></td></tr>'
                                    + '<tr><th>信息来源</th><td>' + ((typeof (dataJson.DamageSourseName) !== 'undefined') ? dataJson.DamageSourseName : '--') + '</td><th>预期完成(天)</th><td>' + ((typeof (dataJson.expectedtimes) !== 'undefined') ? dataJson.expectedtimes : '--') + '</td></tr>'
                                    + '<tr><th>采集人</th><td>' + dataJson.userName + '</td><th>采集时间</th><td>' + facilityMaintenanceObj.getDateInfo(dataJson.collectiondate) + '</td></tr>'
                                    + '<tr><th>病害位置</th><td>' + dataJson.damageposision + '</td></tr>';
									$(e.currentTarget.Ac).find('#gbclod').click(function () {
									    $(e.currentTarget.Ac).find('.pointDisNCz').remove();
									})
                            } else if (type === 4) {
                                ajax.get(baseUrl + "/jcjgl/main/dzdp/getmanholeinfoordamageinfobyfid?fid=" + dataJson.fid, {}, false)
                                    .then(res => {
                                        /* 转换成json对象 */
                                        let jsonData = JSON.parse(res);
                                        if (jsonData.code === 1) {
                                            html = '<tr><th>病害编码</th><td>' + jsonData.DamageCode + '</td><th>井盖编码</th><td>' + jsonData.ManholeCode + '</td></tr>'
                                                + '<tr><th>检查井类型</th><td>' + jsonData.ManholeType + '</td><th>路段名称</th><td>' + jsonData.RoadSectionName + '</td></tr>'
                                                + '<tr><th>所在位置</th><td>' + jsonData.PositionName + '</td><th>井盖材质</th><td>' + jsonData.MaterialName + '</td></tr>'
                                                + '<tr><th>井盖规格</th><td>' + jsonData.ShapeSize + '</td><th>形状</th><td>' + jsonData.ShapeName + '</td></tr>'
                                                + '<tr><th>修复方式</th><td>' + jsonData.RepairStateName + '</td><th>修复进度</th><td>' + jsonData.RepairProgressName + '</td></tr>'
                                                + '<tr><th>方向</th><td>' + jsonData.RoadDirectionName + '</td><th>处理类型</th><td></td></tr>'
                                                + '<tr><th>井盖位置</th><td>' + jsonData.ManholePos + '</td></tr>';
                                            htmlStr += html;
                                            htmlStr += '</table></div></div>';
                                            $(e.currentTarget.Ac).append(htmlStr);
											$(e.currentTarget.Ac).find('#gbclod').click(function () {
											    $(e.currentTarget.Ac).find('.pointDisNCz').remove();
											})
                                        }
                                    })
                                    .catch(err => {
                                        console.error(err)
                                    });
                            } else if (type === 5) {
                                /* 有证/无证 */
                                let haveLicense = '无证';
                                if (typeof (dataJson.havelicense) !== 'undefined' && $.trim(dataJson.havelicense) !== '' && dataJson.havelicense === 1) {
                                    haveLicense = '有证';
                                }
                                /* 完成状态: 0为否，1为已完成，2为结束 */
                                let finishStatusName = '否';
                                if (typeof (dataJson.finishstatus) !== 'undefined' && $.trim(dataJson.finishstatus) !== '') {
                                    if (dataJson.finishstatus === 1) {
                                        finishStatusName = '已完成';
                                    } else if (dataJson.finishstatus === 2) {
                                        finishStatusName = '结束';
                                    }
                                }
                                html = '<tr><th>病害编码</th><td>' + dataJson.damagecode + '</td><th>区域名称</th><td>' + dataJson.locationName + '</td></tr>'
                                    + '<tr><th>道路名称</th><td>' + dataJson.roadInfoName + '</td><th>开挖单位</th><td>' + dataJson.excavationofficename + '</td></tr>'
                                    + '<tr><th>开挖性质</th><td>' + dataJson.excavationNatureName + '</td><th>处理方式</th><td>' + dataJson.treatmentName + '</td></tr>'
                                    + '<tr><th>维修班组</th><td>' + dataJson.repairName + '</td><th>有证/无证</th><td>' + haveLicense + '</td></tr>'
                                    + '<tr><th>完成状态</th><td>' + finishStatusName + '</td><th>录入时间</th><td>' + ((typeof (dataJson.addtimes) !== 'undefined') ? dataJson.addtimes : '--') + '</td></tr>'
                                    + '<tr><th>备注</th><td>' + ((typeof (dataJson.remark) !== 'undefined') ? dataJson.remark : '--') + '</td></tr>'
                                    + '<tr><th>地点</th><td>' + dataJson.address + '</td></tr>';
                            } else if (type === 6) {
                                ajax.get(baseUrl + "/dlxy/main/dzdp/getbudgetorsettledetail?fid=" + dataJson.fid, {}, false)
                                    .then(res => {
                                        /* 转换成json对象 */
                                        let jsonData = JSON.parse(res);
                                        html = '<tr><th>病害类型</th><td>道路</td><th>病害编号</th><td>' + dataJson.damagecode + '</td></tr>'
                                            + '<tr><th>道路名称</th><td>' + dataJson.roadName + '</td><th>维修班组</th><td></td></tr>'
                                            + '<tr><th>预算小计</th><td>' + jsonData.budgetSum + '</td><th>结算小计</th><td>' + jsonData.settleSum + '</td></tr>';
                                        htmlStr += html;
                                        /* 预算集合 */
										let html3 = '<table class="table" style="margin-bottom: 0;">';
                                        let budgetList = jsonData.budgetList;
                                        if (budgetList.length > 0) {
                                            budgetList.forEach((item, i) => {
                                                if (typeof (item.price) !== 'undefined' && item.price && item.price > 0) {
                                                    html3 += '<tr><th>维修方式</th>' + item.maintainName + '<td></td><th>项目特征</th><td>' + ((typeof (item.projectfeatures) !== 'undefined') ? item.projectfeatures : '--') + '</td></tr>'
                                                        + '<tr><th>施工工序</th><td>' + item.WorkingProcedureName + '</td><th>综合单价</th><td>' + item.price + '</td></tr>'
                                                        + '<tr><th>数量</th><td>' + ((typeof (item.quantity) !== 'undefined') ? item.quantity : '--') + '</td><th>备注</th><td>' + ((typeof (item.remark) !== 'undefined') ? item.remark : '--') + '</td></tr>';
                                                }
                                            });
                                            html3 += '</table>';
                                        }
                                        let html4 = '<table class="table" style="margin-bottom: 0;">';
                                        /* 结算集合 */
                                        let settleList = jsonData.settleList;
                                        if (settleList.length > 0) {
                                            settleList.forEach((item, i) => {
                                                if (typeof (item.price) !== 'undefined' && item.price && item.price > 0) {
                                                    html4 += '<tr><th>维修方式</th>' + item.maintainName + '<td></td><th>项目特征</th><td>' + ((typeof (item.projectfeatures) !== 'undefined') ? item.projectfeatures : '--') + '</td></tr>'
                                                        + '<tr><th>施工工序</th><td>' + item.WorkingProcedureName + '</td><th>综合单价</th><td>' + item.price + '</td></tr>'
                                                        + '<tr><th>数量</th><td>' + ((typeof (item.quantity) !== 'undefined') ? item.quantity : '--') + '</td><th>备注</th><td>' + ((typeof (item.remark) !== 'undefined') ? item.remark : '--') + '</td></tr>';
                                                }
                                            });
                                            html4 += '</table>';
                                        }
										let html2 = '<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief"><ul class="layui-tab-title"><li class="layui-this">预算集合</li><li>结算集合</li></ul><div class="layui-tab-content"> <div class="layui-tab-item layui-show">{预算集合}</div><div class="layui-tab-item">{结算集合}</div></div></div>';
										html2= html2.replace('{预算集合}',html3);
										html2= html2.replace('{结算集合}',html4);
										layui.use('element', function(){
										  var element = layui.element;
										})
                                        htmlStr += '</table>' + html2 +'</div></div>';
                                        $(e.currentTarget.Ac).append(htmlStr);
										$(e.currentTarget.Ac).find('#gbclod').click(function () {
										    $(e.currentTarget.Ac).find('.pointDisNCz').remove();
										})
                                    })
                                    .catch(err => {
                                        console.error(err)
                                    });
                            } else {
                                html = '暂无数据！';
                            }
                            if (type !== 4 && type !== 6) {
                                htmlStr += html;
                                htmlStr += '</table></div></div>';
                                $(e.currentTarget.Ac).append(htmlStr);
                            }
                            $(e.currentTarget.Ac).find('#gbclod').click(function () {
                                $(e.currentTarget.Ac).find('.pointDisNCz').remove();
                            })
                        }
                    }
                });
                map.addOverlay(marker);
            })
        }
    },
    /**
     * 时间戳转换成日期格式函数
     * @param longDate 时间戳
     */
    getDateInfo: function (longDate) {
        let dateTypeDate = "";
        let date = new Date();
        date.setTime(longDate);
        dateTypeDate += date.getFullYear(); //年
        dateTypeDate += "-" + facilityMaintenanceObj.getMonth(date); //月
        dateTypeDate += "-" + facilityMaintenanceObj.getDay(date); //日
        return dateTypeDate;
    },
    /**
     * 获取月份
     * @param date 时间
     */
    getMonth: function (date) {
        let month = "";
        month = date.getMonth() + 1; //getMonth()得到的月份是0-11
        if (month < 10) {
            month = "0" + month;
        }
        return month;
    },
    /**
     * 获取天
     * @param date 时间
     */
    getDay: function (date) {
        let day = "";
        day = date.getDate();
        if (day < 10) {
            day = "0" + day;
        }
        return day;
    }
}
